﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IrisGenerator.Common.UI.UserControls;
using IrisGenerator.Common.UI.Controls.Lists;
using IrisGenerator.Common.UI.Controls.DataGrids;

namespace IrisGenerator.WinGui
{
    public partial class Preferences : BaseForm
    {
        public Preferences()
        {
            InitializeComponent();
            this.tvwOptions.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvwOptions_AfterSelect);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.tvwOptions.ExpandAll();
        }

        private void tvwOptions_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Tag != null)
            {
                Control ctrl = null;
                switch (e.Node.Tag.ToString().ToUpper())
                {
                    case "METATYPE":
                        ctrl =new MetatypeDataGrid();
                        ChangeControl(ctrl);
                        break;
                    case "TARGET":
                        ctrl = new TargetDataGrid();
                        ChangeControl(ctrl);
                        break;
                    case "METATYPE_EQUIVALENCES":
                        ctrl = new MetaTypeEquivalencesGridView();
                        ChangeControl(ctrl);
                        break;
                    case "MODULES":
                        ctrl = new ModuleList();
                        ChangeControl(ctrl);
                        break;
                    default:
                        break;
                }
            }
            
        }

        private Control ChangeControl(Control ctrl)
        {
            if (ctrl == null)
                return null;
            this.OptionPanel.Hide();
            this.OptionPanel.Controls.Clear();
            ctrl.Dock = DockStyle.Fill;
            this.OptionPanel.Controls.Add(ctrl);
            this.OptionPanel.Show();
            return ctrl;
        }
    }
}
